<template>
  <div class="module m15">
    <el-tabs :tab-position="tabPosition" @tab-click="changeTab">
      <el-tab-pane label="评价体系管理">
        <div style="padding-left:10px;padding-top:10px;">
          <!--安全等级-->
          <div class="itemTitle">
            安全等级
            <div class="fr itemTitleBtn pr">
              <el-button type="primary" plain size="mini" @click="addSecurityLevels">增加</el-button>
              <el-button type="danger" plain size="mini">删除</el-button>
            </div>
          </div>
          <el-table border ref="multipleTable" :data="tableData1" tooltip-effect="dark" v-loading="securityLevelsLoading" style="width: 100%" @selection-change="handleSelectionChange">
            <el-table-column type="selection"width="55"></el-table-column>
            <el-table-column prop="levelSeq"label="等级序号" width="80"></el-table-column>
            <el-table-column prop="levelName"label="等级名称" width="200"></el-table-column>
            <el-table-column prop="levelDesc" label="等级说明" ></el-table-column>
            <el-table-column label="操作" width="120">
              <template slot-scope="scope">
                <el-link icon="el-icon-edit" :underline="false" type="primary" @click="editSecurityLevels(scope.row)">修改</el-link>
                <el-link icon="el-icon-delete" :underline="false" type="danger" @click="delSecurityLevels(scope.row.id)">删除</el-link>
              </template>
            </el-table-column>
          </el-table>
          <div class="fc" style="margin-bottom:15px;margin-top:10px;">
            <el-pagination class="fr" background layout="total, prev, pager, next" :total="securityLevelsTotalCount" :page-size="securityLevelsPageSize" @current-change="changeSecurityLevelsPage"></el-pagination>
          </div>
          <!--安全指标-->
          <div class="itemTitle">
            安全指标
            <div class="fr itemTitleBtn pr">
              <el-button type="primary" plain size="mini" @click="addSecurityIndicators">增加</el-button>
              <el-button type="danger" plain size="mini">删除</el-button>
            </div>
          </div>
          <el-table border ref="multipleTable" :data="tableData2" tooltip-effect="dark" v-loading="securityIndicatorsLoading" style="width: 100%" @selection-change="handleSelectionChange">
            <el-table-column type="selection"width="55"></el-table-column>
            <el-table-column prop="indicatorDimension" label="安全维度" width="200" :formatter="formatterIndicatorDimension"></el-table-column>
            <el-table-column prop="indicatorName" label="指标名称" width="300"></el-table-column>
            <el-table-column prop="indicatorValue" label="指标选项（用‘|’分割）" ></el-table-column>
            <el-table-column prop="indicatorCode" label="指标编码" ></el-table-column>
            <el-table-column label="操作" width="120">
              <template slot-scope="scope">
                <el-link icon="el-icon-edit" :underline="false" type="primary" @click="editSecurityIndicators(scope.row)">修改</el-link>
                <el-link icon="el-icon-delete" :underline="false" type="danger" @click="delSecurityIndicators(scope.row.id)">删除</el-link>
              </template>
            </el-table-column>
          </el-table>
          <div class="fc" style="margin-bottom:15px;margin-top:10px;">
            <el-pagination class="fr" background layout="total, prev, pager, next" :total="securityIndicatorsTotalCount" :page-size="securityIndicatorsPageSize" @current-change="changeSecurityIndicatorsPage"></el-pagination>
          </div>
        </div>
      </el-tab-pane>
      <el-tab-pane label="内置规则管理">
        <div style="padding-left:10px;padding-top:10px;">
          <div class="itemTitle">
            安全规则
            <div class="fr itemTitleBtn pr">
              <el-button type="primary" plain size="mini" @click="addSecurityRules">增加</el-button>
              <el-button type="danger" plain size="mini">删除</el-button>
            </div>
          </div>
          <el-table border ref="multipleTable" :data="tableData3" tooltip-effect="dark" v-loading="securityRulesLoading" style="width: 100%" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55"></el-table-column>
            <el-table-column prop="ruleType" label="规则类型" width="75" :formatter="formatterRulesTable"></el-table-column>
            <el-table-column prop="ruleDomain" label="规则适用范围" width="95" :formatter="formatterRulesTable"></el-table-column>
            <el-table-column prop="jdbcConfigId" label="数据源名称" width="120" :formatter="formatterRulesTable"></el-table-column>
            <el-table-column prop="ruleScope" label="规则作用域" width="100" :formatter="formatterRulesTable"></el-table-column>
            <el-table-column prop="ruleContent" label="规则内容"></el-table-column>
            <el-table-column prop="rulePriority" label="优先级" width="60" align="center"></el-table-column>
            <el-table-column prop="ruleDesc" label="规则说明" width="150"></el-table-column>
            <el-table-column prop="createDate" label="创建时间" width="150"></el-table-column>
            <el-table-column label="操作" width="110">
              <template slot-scope="scope">
                <el-link icon="el-icon-edit" :underline="false" type="primary" @click="editSecurityRules(scope.row)">修改</el-link>
                <el-link icon="el-icon-delete" :underline="false" type="danger" @click="delSecurityRules(scope.row.id)">删除</el-link>
              </template>
            </el-table-column>
          </el-table>
          <div class="fc" style="margin-bottom:15px;margin-top:10px;">
            <el-pagination class="fr" background layout="total, prev, pager, next" :total="securityRulesTotalCount" :page-size="securityRulesPageSize" @current-change="changeSecurityRulesPage"></el-pagination>
          </div>
        </div>
      </el-tab-pane>
    </el-tabs>
    <!--安全等级form表单-->
    <el-dialog :title="securityLevelsFormTitle" :visible.sync="securityLevelsFormVisible" width="400px">
      <el-form :model="securityLevelsForm" :rules="securityLevelsRules" ref="securityLevels" label-width="80px">
        <el-form-item label="等级序号" prop="levelSeq">
          <el-input v-model="securityLevelsForm.levelSeq" autocomplete="off" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="等级名称" prop="levelName">
          <el-input v-model="securityLevelsForm.levelName" autocomplete="off" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="等级说明">
          <el-input type="textarea" v-model="securityLevelsForm.levelDesc"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="securityLevelsFormVisible = false" size="mini">取 消</el-button>
        <el-button type="primary" @click="submitSecurityLevels" size="mini">确 定</el-button>
      </div>
    </el-dialog>
    <!--安全指标form表单-->
    <el-dialog :title="securityIndicatorsFormTitle" :visible.sync="securityIndicatorsFormVisible" width="400px">
      <el-form :model="securityIndicatorsForm" :rules="securityIndicatorsRules" ref="securityIndicators" label-width="80px">
        <el-form-item label="安全维度" prop="indicatorDimension">
          <el-select v-model="securityIndicatorsForm.indicatorDimension" placeholder="请选择" size="mini" style="width: 100%">
            <el-option v-for="(item, index) in indicatorDimensionList" :key="index" :label="item.name" :value="item.val"></el-option>
          </el-select>
          <!--<el-input v-model="securityIndicatorsForm.indicatorDimension" autocomplete="off" size="mini"></el-input>-->
        </el-form-item>
        <el-form-item label="指标名称" prop="indicatorName">
          <el-input v-model="securityIndicatorsForm.indicatorName" autocomplete="off" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="指标选项" prop="indicatorValue">
          <el-input v-model="securityIndicatorsForm.indicatorValue" autocomplete="off" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="指标编码" prop="indicatorCode">
          <el-input v-model="securityIndicatorsForm.indicatorCode" autocomplete="off" size="mini"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="securityIndicatorsFormVisible = false" size="mini">取 消</el-button>
        <el-button type="primary" @click="submitSecurityIndicators" size="mini">确 定</el-button>
      </div>
    </el-dialog>
    <!--安全规则form表单-->
    <el-dialog :title="securityRulesFormTitle" :visible.sync="securityRulesFormVisible" width="600px">
      <el-form :model="securityRulesForm" :rules="securityRulesRules" ref="securityRules" label-width="120px">
        <el-form-item label="规则类型" prop="ruleType">
          <el-select v-model="securityRulesForm.ruleType" placeholder="请选择" size="mini" style="width: 100%">
            <el-option v-for="(item, index) in rulesTypeList" :key="index" :label="item.name" :value="item.val"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="规则适用范围" prop="ruleDomain">
          <el-select v-model="securityRulesForm.ruleDomain" placeholder="请选择" size="mini" style="width: 100%">
            <el-option v-for="(item, index) in ruleDomainList" :key="index" :label="item.name" :value="item.val"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="指定数据源" prop="jdbcConfigId" v-if="securityRulesForm.ruleDomain=='datasource'">
          <el-select v-model="securityRulesForm.jdbcConfigId" placeholder="请选择" size="mini" style="width: 100%">
            <el-option v-for="(item, index) in jdbcConfigsList" :key="index" :label="item.dsName" :value="item.id"></el-option>
          </el-select>
          <!--<el-input v-model="securityRulesForm.jdbcConfigId" autocomplete="off" size="mini"></el-input>-->
        </el-form-item>
        <el-form-item label="规则作用域" prop="ruleScope">
          <el-select v-model="securityRulesForm.ruleScope" placeholder="请选择" size="mini" style="width: 100%">
            <el-option v-for="(item, index) in ruleScopeList" :key="index" :label="item.name" :value="item.val"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="规则内容">
          <el-input type="textarea" v-model="securityRulesForm.ruleContent"></el-input>
        </el-form-item>
        <el-form-item label="规则优先级" prop="rulePriority">
          <el-input v-model="securityRulesForm.rulePriority" autocomplete="off" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="规则说明">
          <el-input type="textarea" v-model="securityRulesForm.ruleDesc"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="securityRulesFormVisible = false" size="mini">取 消</el-button>
        <el-button type="primary" @click="submitSecurityRules" size="mini">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "Module",
  data () {
    return {
      tabPosition: 'left',
      tableData1: [], // ------------------------------安全等级
      securityLevelsTotalCount: 0,
      securityLevelsPageSize: 10,
      securityLevelsSort: 'levelSeq',
      securityLevelsFormVisible: false,
      securityLevelsFormTitle: '添加安全等级',
      securityLevelsForm: {
        id: '',
        levelName: '',
        levelDesc: '',
        levelSeq: ''
      },
      securityLevelsRules: {
        levelSeq: {required: true, message: '请输入等级序号', trigger: 'blur'},
        levelName: {required: true, message: '请输入等级序号', trigger: 'blur'}
      },
      securityLevelsLoading: false,
      tableData2: [], // -----------------------------安全指标
      securityIndicatorsTotalCount: 0,
      securityIndicatorsPageSize: 10,
      securityIndicatorsSort: 'indicatorDimension',
      securityIndicatorsFormVisible: false,
      securityIndicatorsFormTitle: '添加安全指标',
      securityIndicatorsForm: {
        id: '',
        indicatorName: '',
        indicatorCode: '',
        indicatorValue: '',
        indicatorDimension: ''
      },
      securityIndicatorsRules: {
        indicatorName: {required: true, message: '请输入指标名称', trigger: 'blur'},
        indicatorCode: {required: true, message: '请输入指标编码', trigger: 'blur'},
        indicatorValue: {required: true, message: '请输入指标选项', trigger: 'blur'},
        indicatorDimension: {required: true, message: '请输入指标维度', trigger: 'blur'}
      },
      securityIndicatorsLoading: false,
      indicatorDimensionList: [
        {name: '保密性', val: 'confidentiality'},
        {name: '完整性', val: 'integrity'},
        {name: '可用性', val: 'availability'}
      ],
      tableData3: [], // -----------------------------内置规则
      securityRulesTotalCount: 0,
      securityRulesPageSize: 10,
      securityRulesSort: 'createDate',
      securityRulesFormVisible: false,
      securityRulesFormTitle: '添加安全规则',
      securityRulesForm: {
        id: '',
        ruleType: '',
        ruleDomain: '',
        jdbcConfigId: '',
        ruleScope: '',
        ruleContent: '',
        rulePriority: '',
        ruleDesc: ''
      },
      securityRulesRules: {
        ruleType: {required: true, message: '请选择规则类型', trigger: 'blur'},
        ruleDomain: {required: true, message: '请选择适用范围', trigger: 'blur'},
        ruleScope: {required: true, message: '请选择作用域', trigger: 'blur'},
      },
      rulesTypeList: [
        {name: '用户设定', val: 'user'},
        {name: '程序生成', val: 'auto'}
      ],
      ruleDomainList: [
        {name: '全局', val: 'global'},
        {name: '指定数据源', val: 'datasource'}
      ],
      ruleScopeList: [
        {name: '指标特征传导', val: 'indicator_scope'},
        {name: '可用性分级', val: 'ava_scope'},
        {name: '完整性分级', val: 'itg_scope'},
        {name: '保密性分级', val: 'cfd_scope'},
        {name: '安全等级分级', val: 'sle_scope'},
        {name: '字段分级', val: 'column_scope'},
        {name: '接口分级', val: 'interface_scope'}
      ],
      securityRulesLoading: false,
      jdbcConfigsList: [], // 数据源列表
      multipleSelection: []
    }
  },
  mounted () {
    this.getJdbcConfigs('desc') // 获取数据源
    this.changeTab({index: '0'})
  },
  methods: {
    // tab页切换
    changeTab (val) {
      if (val.index === '0') {
        this.getSecurityLevels(1, this.securityLevelsPageSize, this.securityLevelsSort)
        this.getSecurityIndicators(1, this.securityIndicatorsPageSize, this.securityIndicatorsSort)
      } else {
        this.getSecurityRules(1, this.securityRulesPageSize, this.securityRulesSort)
      }
    },
    // 获取数据源
    getJdbcConfigs (sort) {
      this.jdbcConfigsLoading = true
      this.axios.get('/jdbcconfigs?getType=all&sort=' + sort).then(res => {
        if (res.status === 200) {
          this.jdbcConfigsList  = res.data
        } else {
          this.$commonFunc.message({type: 'error', message: res.statusText})
        }
      })
    },
    /*
    * 获取安全等级
    * params pageNum 页码， pageSize 页大小， sort 排序（column,desc）
    * */
    getSecurityLevels (pageNum, pageSize, sort) {
      this.securityLevelsLoading = true
      this.axios.get('/securitylevels?getType=page&pageNum=' + pageNum + '&pageSize=' + pageSize + '&sort=' + sort).then(res => {
        this.securityLevelsLoading = false
        if (res.status === 200) {
          this.tableData1 = res.data.content
          this.securityLevelsTotalCount = res.data.totalElements
        } else {
          this.$commonFunc.message({type: 'error', message: res.statusText})
        }
      })
    },
    changeSecurityLevelsPage (page) {
      this.getSecurityLevels(page, this.securityLevelsPageSize, this.securityLevelsSort)
    },
    addSecurityLevels () {
      if (this.$refs.securityLevels) {
        this.$refs.securityLevels.resetFields()
      }
      this.securityLevelsFormTitle = '添加安全等级'
      this.securityLevelsForm.id = ''
      this.securityLevelsForm.levelSeq = ''
      this.securityLevelsForm.levelName = ''
      this.securityLevelsForm.levelDesc = ''
      this.securityLevelsFormVisible = true
    },
    editSecurityLevels (row) {
      if (this.$refs.securityLevels) {
        this.$refs.securityLevels.resetFields()
      }
      this.securityLevelsFormTitle = '编辑安全等级'
      this.securityLevelsForm.id = row.id
      this.securityLevelsForm.levelSeq = row.levelSeq
      this.securityLevelsForm.levelName = row.levelName
      this.securityLevelsForm.levelDesc = row.levelDesc
      this.securityLevelsFormVisible = true
    },
    delSecurityLevels (id) {
      let that = this
      this.$commonFunc.message({type: 'confirm', message: '您确定要删除该数据吗?'}, function () {
        that.axios.delete('/securitylevels/' + id).then(res => {
          if (res.status === 200) {
            that.$commonFunc.message({type: 'success', message: '删除成功'})
            that.getSecurityLevels(1, that.securityLevelsPageSize, that.securityLevelsSort)
          } else {
            that.$commonFunc.message({type: 'error', message: res.statusText})
          }
        })
      })
    },
    submitSecurityLevels () {
      this.$refs.securityLevels.validate((valid) => {
        if (valid) {
          let url = ''
          let tip = ''
          let method = ''
          if (this.securityLevelsForm.id === '') { // 添加
            url = '/securitylevels'
            tip = '添加成功'
            method = 'post'
          } else {
            url = '/securitylevels/' + this.securityLevelsForm.id
            tip = '编辑成功'
            method = 'put'
          }
          this.axios({
            method: method,
            url: url,
            data: {
              levelSeq: this.securityLevelsForm.levelSeq,
              levelName: this.securityLevelsForm.levelName,
              levelDesc: this.securityLevelsForm.levelDesc
            }
          }).then(res => {
            if (res.status === 200) {
              this.$commonFunc.message({type: 'success', message: tip})
              this.getSecurityLevels(1, this.securityLevelsPageSize, this.securityLevelsSort)
              this.securityLevelsFormVisible = false
            } else {
              this.$commonFunc.message({type: 'error', message: res.statusText})
            }
          })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    /*
    * 获取安全指标
    * 参数 pageNum 页码， pageSize 页大小， sort 排序（column,desc）
    * */
    getSecurityIndicators (pageNum, pageSize, sort) {
      this.securityIndicatorsLoading = true
      this.axios.get('/securityindicators?getType=page&pageNum=' + pageNum + '&pageSize=' + pageSize + '&sort=' + sort).then(res => {
        this.securityIndicatorsLoading = false
        if (res.status === 200) {
          this.tableData2 = res.data.content
          this.securityIndicatorsTotalCount = res.data.totalElements
        } else {
          this.$commonFunc.message({type: 'error', message: res.statusText})
        }
      })
    },
    changeSecurityIndicatorsPage (page) {
      this.getSecurityIndicators(page, this.securityIndicatorsPageSize, this.securityIndicatorsSort)
    },
    addSecurityIndicators () {
      if (this.$refs.securityIndicators) {
        this.$refs.securityIndicators.resetFields()
      }
      this.securityIndicatorsFormTitle = '添加安全指标'
      this.securityIndicatorsForm.id = ''
      this.securityIndicatorsForm.indicatorName = ''
      this.securityIndicatorsForm.indicatorCode = ''
      this.securityIndicatorsForm.indicatorValue = ''
      this.securityIndicatorsForm.indicatorDimension = ''
      this.securityIndicatorsFormVisible = true
    },
    editSecurityIndicators (row) {
      if (this.$refs.securityIndicators) {
        this.$refs.securityIndicators.resetFields()
      }
      this.securityIndicatorsFormTitle = '编辑安全指标'
      this.securityIndicatorsForm.id = row.id
      this.securityIndicatorsForm.indicatorName = row.indicatorName
      this.securityIndicatorsForm.indicatorCode = row.indicatorCode
      this.securityIndicatorsForm.indicatorValue = row.indicatorValue
      this.securityIndicatorsForm.indicatorDimension = row.indicatorDimension
      this.securityIndicatorsFormVisible = true
    },
    delSecurityIndicators (id) {
      let that = this
      this.$commonFunc.message({type: 'confirm', message: '您确定要删除该数据吗?'}, function () {
        that.axios.delete('/securityindicators/' + id).then(res => {
          if (res.status === 200) {
            that.$commonFunc.message({type: 'success', message: '删除成功'})
            that.getSecurityIndicators(1, that.securityIndicatorsPageSize, that.securityIndicatorsSort)
          } else {
            that.$commonFunc.message({type: 'error', message: res.statusText})
          }
        })
      })
    },
    submitSecurityIndicators () {
      this.$refs.securityIndicators.validate((valid) => {
        if (valid) {
          let url = ''
          let tip = ''
          let method = ''
          if (this.securityIndicatorsForm.id === '') { // 添加
            url = '/securityindicators'
            tip = '添加成功'
            method = 'post'
          } else {
            url = '/securityindicators/' + this.securityIndicatorsForm.id
            tip = '编辑成功'
            method = 'put'
          }
          this.axios({
            method: method,
            url: url,
            data: {
              indicatorName: this.securityIndicatorsForm.indicatorName,
              indicatorCode: this.securityIndicatorsForm.indicatorCode,
              indicatorValue: this.securityIndicatorsForm.indicatorValue,
              indicatorDimension: this.securityIndicatorsForm.indicatorDimension
            }
          }).then(res => {
            if (res.status === 200) {
              this.$commonFunc.message({type: 'success', message: tip})
              this.getSecurityIndicators(1, this.securityIndicatorsPageSize, this.securityIndicatorsSort)
              this.securityIndicatorsFormVisible = false
            } else {
              this.$commonFunc.message({type: 'error', message: res.statusText})
            }
          })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    /*
    * 获取安全规则
    * 参数 pageNum 页码， pageSize 页大小， sort 排序（column,desc）
    * */
    getSecurityRules (pageNum, pageSize, sort) {
      this.securityRulesLoading = true
      this.axios.get('/securityrules?getType=page&pageNum=' + pageNum + '&pageSize=' + pageSize + '&sort=' + sort).then(res => {
        this.securityRulesLoading = false
        if (res.status === 200) {
          this.tableData3 = res.data.content
          this.securityRulesTotalCount = res.data.totalElements
        } else {
          this.$commonFunc.message({type: 'error', message: res.statusText})
        }
      })
    },
    changeSecurityRulesPage (page) {
      this.getSecurityRules(page, this.securityRulesPageSize, this.securityRulesSort)
    },
    addSecurityRules () {
      if (this.$refs.securityRules) {
        this.$refs.securityRules.resetFields()
      }
      this.securityRulesFormTitle = '添加安全规则'
      this.securityRulesForm.id = ''
      this.securityRulesForm.ruleType = ''
      this.securityRulesForm.ruleDomain = ''
      this.securityRulesForm.jdbcConfigId = ''
      this.securityRulesForm.ruleScope = ''
      this.securityRulesForm.ruleContent = ''
      this.securityRulesForm.rulePriority = ''
      this.securityRulesForm.ruleDesc = ''
      this.securityRulesFormVisible = true
    },
    editSecurityRules (row) {
      if (this.$refs.securityRules) {
        this.$refs.securityRules.resetFields()
      }
      this.securityRulesFormTitle = '编辑安全规则'
      this.securityRulesForm.id = row.id
      this.securityRulesForm.ruleType = row.ruleType
      this.securityRulesForm.ruleDomain = row.ruleDomain
      this.securityRulesForm.jdbcConfigId = row.jdbcConfigId
      this.securityRulesForm.ruleScope = row.ruleScope
      this.securityRulesForm.ruleContent = row.ruleContent
      this.securityRulesForm.rulePriority = row.rulePriority
      this.securityRulesForm.ruleDesc = row.ruleDesc
      this.securityRulesFormVisible = true
    },
    delSecurityRules (id) {
      let that = this
      this.$commonFunc.message({type: 'confirm', message: '您确定要删除该数据吗?'}, function () {
        that.axios.delete('/securityrules/' + id).then(res => {
          if (res.status === 200) {
            that.$commonFunc.message({type: 'success', message: '删除成功'})
            that.getSecurityRules(1, that.securityRulesPageSize, that.securityRulesSort)
          } else {
            that.$commonFunc.message({type: 'error', message: res.statusText})
          }
        })
      })
    },
    submitSecurityRules () {
      this.$refs.securityRules.validate((valid) => {
        if (valid) {
          let url = ''
          let tip = ''
          let method = ''
          if (this.securityRulesForm.id === '') { // 添加
            url = '/securityrules'
            tip = '添加成功'
            method = 'post'
          } else {
            url = '/securityrules/' + this.securityRulesForm.id
            tip = '编辑成功'
            method = 'put'
          }
          this.axios({
            method: method,
            url: url,
            data: {
              ruleType: this.securityRulesForm.ruleType,
              ruleDomain: this.securityRulesForm.ruleDomain,
              jdbcConfigId: this.securityRulesForm.jdbcConfigId,
              ruleScope: this.securityRulesForm.ruleScope,
              ruleContent: this.securityRulesForm.ruleContent,
              rulePriority: this.securityRulesForm.rulePriority,
              ruleDesc: this.securityRulesForm.ruleDesc
            }
          }).then(res => {
            if (res.status === 200) {
              this.$commonFunc.message({type: 'success', message: tip})
              this.getSecurityRules(1, this.securityRulesPageSize, this.securityRulesSort)
              this.securityRulesFormVisible = false
            } else {
              this.$commonFunc.message({type: 'error', message: res.statusText})
            }
          })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    formatterIndicatorDimension (row, column, cellValue, index) {
      if (row.indicatorDimension === 'confidentiality') {
        return '保密性'
      } else if (row.indicatorDimension === 'integrity') {
        return '完整性'
      } else if (row.indicatorDimension === 'availability') {
        return '可用性'
      }
    },
    formatterRulesTable (row, column, cellValue, index) {
      if (column.property === 'ruleType') {
        let obj = this.rulesTypeList.find(v => v.val === cellValue)
        return obj.name
      } else if (column.property === 'ruleDomain') {
        let obj = this.ruleDomainList.find(v => v.val === cellValue)
        return obj.name
      } else if (column.property === 'ruleScope') {
        let obj = this.ruleScopeList.find(v => v.val === cellValue)
        return obj.name
      } else if (column.property === 'jdbcConfigId') { // 指定数据源
        let dsName = ''
        for (let i = 0; i < this.jdbcConfigsList.length; i++) {
          if (this.jdbcConfigsList[i].id === row.jdbcConfigId) {
            dsName = this.jdbcConfigsList[i].dsName
            break
          }
        }
        return dsName
      }
    },
    handleSelectionChange(val) {
      this.multipleSelection = val
    }
  }
}
</script>

<style scoped>

</style>
